package com.hongdee.insurance.company.dao.impl;

import com.hongdee.base.basedao.impl.BaseDaoImpl;
import com.hongdee.insurance.company.dao.ITinsuranceCompanyBillDao;
import com.hongdee.insurance.company.entity.TInsuranceCompanyBill;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * @author 王帅
 * @className ${CLASS_NAME}
 * @type
 * @description
 * @path com.hongdee.insurance.company.dao.impl
 * @create 2017/6/14 9:09
 **/
@Component
public class TInsuranceCompanyBillDaoImpl extends BaseDaoImpl implements ITinsuranceCompanyBillDao {
    @Override
    public TInsuranceCompanyBill getInfo(String id) throws Exception {
        String hql="from TInsuranceCompanyBill where id=:id";
        Map<String,Object> params=new HashMap<>();
        params.put("id",id);
        return (TInsuranceCompanyBill) this.getHibernateDao().findEntityByHqlWithParams(hql,params);
    }

    @Override
    public Map getAdjustByDetail(String adjustLogId,String billId) throws Exception {
        String sql="select sum(poundage_price*1) poundagePrices from T_INSURANCE_COMPANY_BILL_BALANCE_DETAIL where adjust_id=? and bill_id=? and poundage_price>0 group by adjust_id";
        return getJdbcDao().queryForMapBySqlWithParams(sql,adjustLogId,billId);
    }
}
